package cuongnh.project.japanesediary.vocabulary.dao;

import java.util.Date;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.transaction.annotation.Transactional;

import cuongnh.project.japanesediary.vocabulary.model.PartOfSpeech;

@Transactional
public class PartOfSpeechDao extends HibernateDaoSupport {

	public void save(PartOfSpeech a1) {
		a1.setCreatedDate(new Date());
		a1.setModifiedDate(new Date());
		getHibernateTemplate().save(a1);
	}

	/**
	 * 'load' returns a proxy with only the id populated. To access members in
	 * the proxy requires a Hibernate session. Haven't figured out how to do
	 * transactions between bundles yet...
	 */
	public PartOfSpeech load(long id) {
		return (PartOfSpeech) getHibernateTemplate().load(PartOfSpeech.class, id);
	}

	public PartOfSpeech get(long id) {		
		return (PartOfSpeech) getHibernateTemplate().get(PartOfSpeech.class, id);
	}

	public void update(PartOfSpeech a1) {
		a1.setModifiedDate(new Date());
		getHibernateTemplate().update(a1);
	}

	public void delete(PartOfSpeech a1) {
		getHibernateTemplate().delete(a1);
	}
	
	public List<PartOfSpeech> getAll(){
		return getHibernateTemplate().loadAll(PartOfSpeech.class);
	}

}
